package com.easychat.mychat.common.webSocket;


import com.easychat.mychat.common.entity.constants.Constants;
import com.easychat.mychat.common.entity.dto.MessageSendDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description
 * @Author susu
 * @Date 2024/9/27
 */
@Component
@Slf4j
public class MessageConsumer {

    @Resource
    private ChannelContextUtils channelContextUtils;

    @RabbitListener(queues = Constants.QUEUE_CHAT_NAME)
    public void receiveMessage(MessageSendDto messageSendDto){
        channelContextUtils.sendMessage(messageSendDto);
        log.info("消息已接收：{}",messageSendDto);
    }
}
